<?php
return [
    'module' => [
        'name' => 'product_sku',
        'title' => '商品规格',
        'table' => 'product_skus',
    ],
    
    'fields' => [
        'id' => [
            'type' => 'int',
            'length' => 11,
            'comment' => '规格ID',
            'primary' => true,
            'auto_increment' => true,
            'nullable' => false,
            'required' => true,
        ],
        'product_id' => [
            'type' => 'int',
            'length' => 11,
            'comment' => '商品ID',
            'required' => true,
            'nullable' => false,
        ],
        'code' => [
            'type' => 'varchar',
            'length' => 64,
            'comment' => '规格编码',
            'required' => true,
            'nullable' => false,
        ],
        'name' => [
            'type' => 'varchar',
            'length' => 255,
            'comment' => '规格名称',
            'required' => true,
            'nullable' => false,
        ],
        'image' => [
            'type' => 'varchar',
            'length' => 255,
            'comment' => '规格图片',
            'nullable' => true,
        ],
        'specs' => [
            'type' => 'json',
            'comment' => '规格属性',
            'nullable' => false,
        ],
        'price' => [
            'type' => 'decimal',
            'length' => '10,2',
            'comment' => '销售价格',
            'required' => true,
            'nullable' => false,
        ],
        'original_price' => [
            'type' => 'decimal', 
            'length' => '10,2',
            'comment' => '原价',
            'nullable' => true,
        ],
        'cost_price' => [
            'type' => 'decimal',
            'length' => '10,2', 
            'comment' => '成本价',
            'nullable' => true,
        ],
        'stock' => [
            'type' => 'int',
            'length' => 11,
            'comment' => '库存数量',
            'required' => true,
            'nullable' => false,
            'default' => 0,
        ],
        'sales' => [
            'type' => 'int',
            'length' => 11,
            'comment' => '销量',
            'nullable' => false,
            'default' => 0,
        ],
        'weight' => [
            'type' => 'decimal',
            'length' => '10,2',
            'comment' => '重量(克)',
            'nullable' => true,
        ],
        'volume' => [
            'type' => 'decimal',
            'length' => '10,2',
            'comment' => '体积(立方厘米)',
            'nullable' => true,
        ],
        'is_default' => [
            'type' => 'tinyint',
            'length' => 1,
            'comment' => '是否默认',
            'nullable' => false,
            'default' => 0,
            'options' => [
                0 => '否',
                1 => '是'
            ],
        ],
        'status' => [
            'type' => 'tinyint',
            'length' => 1,
            'comment' => '状态',
            'nullable' => false,
            'default' => 1,
            'options' => [
                0 => '禁用',
                1 => '启用'
            ],
        ],
        'created_at' => [
            'type' => 'timestamp',
            'comment' => '创建时间',
            'nullable' => false,
            'default' => 'CURRENT_TIMESTAMP',
            'raw_default' => true
        ],
        'updated_at' => [
            'type' => 'timestamp',
            'comment' => '更新时间',
            'nullable' => false,
            'default' => 'CURRENT_TIMESTAMP',
            'raw_default' => true,
            'extra' => 'ON UPDATE CURRENT_TIMESTAMP'
        ],
    ],
    
    'relations' => [
        'product' => [
            'type' => 'belongsTo',
            'model' => 'Product',
            'foreign_key' => 'product_id',
        ],
    ],
    
    'queries' => [
        'product_id' => ['=', '?'],
        'code' => ['like', '%?%'],
        'name' => ['like', '%?%'],
        'status' => ['=', '?'],
    ],
]; 